package co.yixiang.yshop.module.product.enums.coupon;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum CouponGetTypeEnum {
    NO_CODE(0, "无码，页面领取"),
    COMMON_CODE(1, "通用码"),
    ONE_2_ONE_CODE(2, "一卡一码"),
    ;
    private int value;
    private String desc;

    public static CouponGetTypeEnum toType(int value) {
        return Stream.of(CouponGetTypeEnum.values())
                .filter(p -> p.value == value)
                .findAny()
                .orElse(null);
    }
}
